<template>
	<view>
		<view class="box">
			<view class="item">
				<view class="title">
					{{name}}
				</view>
			</view>
		</view>
		<!-- <view class="item_nav" v-if="wallet_id!=6&&wallet_id!=8">
			<view class="name">
				ERC20
			</view>
			<input type="text" v-model="trx_address" :placeholder="$t('user.name90')" placeholder-class="input-place" />
		</view> -->
		<view class="item_nav">
			<view class="name">
				BEP20
			</view>
			<input type="text" v-model="bsc_address" :placeholder="$t('user.name90')" placeholder-class="input-place" />
		</view>
		<view class="" style="margin-top: 100rpx;padding: 0 30rpx;">
			<u-button type="primary" :loading="btnloading" :text="$t('vnode.name19')" color="#1e84f1" shape="circle" 
				@click="fatherMethod"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				money:'',
				mobile:'',
				wallet_id:'',
				wallet:{},
				bsc_address:'',
				trx_address:"",
				btnloading:false
			}
		},
		onLoad(option) {
			this.wallet_id=option.id
			this.name=option.name
			uni.setNavigationBarTitle({
				title: option.title
			})
			this.getTxaddrInfo()
		},
		methods: {
			getTxaddrInfo(){
				this.$fun.ajax.post('user/txaddrInfo', {
					wallet_id:this.wallet_id
				}).then(res => {
					this.wallet = res.data?res.data:{},
					this.bsc_address=this.wallet.bsc_address
					this.trx_address=this.wallet.trx_address
				})
			},
			setTxaddr(){
				this.$fun.ajax.post('user/setTxaddr', {
					wallet_id:this.wallet_id,
					trx_address:this.trx_address,
					bsc_address:this.bsc_address
				}).then(res => {
					this.btnloading=false
					if(res.code==1){
						this.trx_address=''
						this.bsc_address=''
						this.$fun.msg(res.msg)
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}
				})
			},
			fatherMethod(){
				console.log(1111)
				this.btnloading=true
				if(!this.trx_address&&!this.bsc_address){
					this.$fun.msg(this.$t('user.name90'))
					this.btnloading=false
					return
				}
				this.setTxaddr()
			}
		}
	}
</script>

<style lang="scss">
.box {
		width: 690rpx;
		height: 160rpx;
		background: #FFFFFF;
		border-radius: 10px;
		margin: 27rpx auto;
		display: flex;
		align-items: center;

		.item {
			margin: 46rpx 80rpx;
			text-align: center;
			width: 100%;

			.title {
				color: #52528C;
				font-family: DIN, DIN;
				font-weight: bold;
				font-size: 44rpx;
				line-height: 75rpx;
			}

			.num {
				color: #121212;
				font-family: DIN, DIN;
				font-weight: bold;
				font-size: 44rpx;
				line-height: 75rpx;
			}
		}

		image {
			width: 128rpx;
			height: 27rpx;
		}
	}

	.item_nav {
		width: 690rpx;
		height: 100rpx;
		margin: 0 auto;
		margin-top: 24rpx;
		background: #FFFFFF;
		align-items: center;
		padding: 20rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		color: #333333;
		display: flex;
		justify-content: space-between;
		margin-bottom: 2rpx;
		font-weight: bold;

		input {
			text-align: end;
		}

		.input-place {
			color: #CCCCCC;
			font-size: 28rpx;
			font-weight: 400;
		}
	}
</style>
